package com.bkhc.umc.api;

import com.bkhc.common.annotation.ApiOperation;
import com.bkhc.common.annotation.ApiPackage;
import com.bkhc.common.annotation.AuditLog;
import com.bkhc.common.enu.OperationEnum;
import com.bkhc.common.util.CommonUtil;
import com.bkhc.common.util.response.ResultJson;
import com.bkhc.common.vo.UserBean;
import com.bkhc.common.vo.UserVo;
import com.bkhc.umc.entity.Address;
import com.bkhc.umc.entity.User;
import com.bkhc.umc.entity.UserRole;
import com.bkhc.umc.service.AddressSerivce;
import com.bkhc.umc.service.UserSerivce;
import com.bkhc.umc.vo.UserInfo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author pcq
 * @date 2021/6/20 17:57
 */
@RestController
@RequestMapping("/address")
@Api("后台管理服务接口")
@ApiPackage(code="userService",name="后台用户服务接口",description = "后台管理员相关维护操作接口")
public class AddressController extends CommonController{

    @Autowired
    private AddressSerivce addressSerivce;
    @ApiOperation(code="queryAddressByUserId",name="查询后台用户的地址",description = "查询后台用户的地址",type  ="common")
    @AuditLog(object="User",operation = "查询后台用户的地址",type = OperationEnum.query)
    @RequestMapping(path = "/queryAddressByUserId",method = RequestMethod.POST)
    public ResultJson<?> queryAddressByUserId(@RequestParam(name="userId") String userId) {
        ResultJson<?> res = addressSerivce.queryAddressByUserId(userId);
        return res;
    }

    @ApiOperation(code="updateAddress",name="修改地址",description = "修改地址",type  ="common")
    @AuditLog(object="Address",operation = "修改地址",type = OperationEnum.query)
    @RequestMapping(path = "/updateAddress",method = RequestMethod.POST)
    public ResultJson<?> updateAddress(@RequestBody Address address) {
        ResultJson<?> res = addressSerivce.updateAddress(address);
        return res;
    }

    @ApiOperation(code="updateDefaultAddress",name="修改默认地址",description = "修改默认地址",type  ="common")
    @AuditLog(object="Address",operation = "修改默认地址",type = OperationEnum.query)
    @RequestMapping(path = "/updateDefaultAddress",method = RequestMethod.POST)
    public ResultJson<?> updateDefaultAddress(@RequestBody Address address) {
        ResultJson<?> res = addressSerivce.updateDefaultAddress(address);
        return res;
    }

    @ApiOperation(code="addAddress",name="增加地址",description = "增加地址",type  ="common")
    @AuditLog(object="Address",operation = "增加地址",type = OperationEnum.query)
    @RequestMapping(path = "/addAddress",method = RequestMethod.POST)
    public ResultJson<?> addAddress(@RequestBody Address address) {
        ResultJson<?> res = addressSerivce.addAddress(address);
        return res;
    }
    @ApiOperation(code="deleteAddress",name="删除地址",description = "删除地址",type  ="common")
    @AuditLog(object="Address",operation = "删除地址",type = OperationEnum.query)
    @RequestMapping(path = "/deleteAddress",method = RequestMethod.POST)
    public ResultJson<?> deleteAddress(@RequestBody Address address) {
        ResultJson<?> res = addressSerivce.deleteAddress(address);
        return res;
    }


}
